package com.example.springsecuritydemo.config;

import com.example.springsecuritydemo.utils.MD5Util;
import org.springframework.security.crypto.password.PasswordEncoder;

/**
 * @author fair_wu
 * @version v1.0
 * @date 2021-03-05 下午 23:21
 */
public class MyPasswordEncoder implements PasswordEncoder {
    @Override
    public String encode(CharSequence rawPassword) {
        return MD5Util.encode((String) rawPassword);
    }

    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {
        return encodedPassword.equals(MD5Util.encode((String) rawPassword));
    }
}
